<!DOCTYPE html>
<html>
<head th:include="cultivateWeb/header :: culHeaderCss">
</head>
<link type="text/css" href="/css/cultivateWeb/style/news.css" rel="stylesheet">
<link type="text/css" href="/css/cultivateWeb/style/teach.css" rel="stylesheet">
<body>
<!-- 顶部导航 -->
<header th:include="cultivateWeb/header :: header"></header>
<div style="clear: both"></div>
<div style="background-color: #f7f7f7; ">
    <div class="layui-container">
        <p style="line-height: 40px">当前位置：<a href="/cultivate/homepage">首页</a> > 师资介绍</p>
    </div>
    <div class="div1">
        <!--<a href="#"><span class="news sz" a="0">师资介绍</span></a>-->
        <div style="margin: 20px auto 20px 30px">
            <input placeholder="讲师姓名" type="text" id="name" class="form-control query_1"/>
            <input type="button" value="搜索" onclick="findName();" class="but" />
        </div>
    </div>
    <div id="tch">
        <div id="teach" style="background-color: #f7f7f7; width: 1200px; margin: 0 auto">
        </div>
        <div id="page" class="page"></div>
    </div>
    <div style="clear: both;margin-bottom: 50px"></div>
</div>

<!-- footer ------------------------------------------------------- -->
<div class="footer" th:include="cultivateWeb/header :: footer"></div>
<script type="text/javascript" src="/js/xlPaging.js"></script>
</body>
<script>
    $(function () {
        getData("")
    });
   function findName() {
       getData($("#name").val())
   }
    function getData(name) {
        //讲师专栏
        $.ajax({
            url: "/jzApi/experts/selExperts",
            type: 'GET',
            data: {
                number:8,
                current: 1,
                name:name,
                type: 4
            },
            success: function (res) {
                console.log("res",res);
                if(res.data.pages==0){
                    $("#teach").html('<div class="noData">暂无数据</div>');
                }else{
                    var list = res.data.records;
                    var news = '';
                    list.forEach(function (item, index) {
                        var a = '';
                        if (item.headPortrait != "" && item.headPortrait != null) {
                            a = item.headPortrait;
                        } else {
                            a = '/img/timg.jpg'
                        }
                        news += '<a href="/cultivate/teacherDetails?id='+item.userId+'"><div id="sz">' +
                            '<div class="tea_1">' +
                            '<img class="tea_2" src="'+a+'">' +
                            '<div class="tea_3">讲师姓名：'+item.name+'</div>' +
                            '<div class="tea_4">所属单位：'+item.orgName+'</div>' +
                            '<div class="tea_4">擅长领域：'+item.kpointsName+'</div>' +
                            '</div>' +
                            '</div></a>';
                    });
                    news +='<div style="clear: both"></div>';
                    $("#teach").html(news);
                    page(1,res.data.pages,name);
                }
            }
        });
    }

    function page(num,tolPages,name) {
        $("#page").paging({
            nowPage:Number(num), // 当前页码
            pageNum:Number(tolPages), // 总页码
            buttonNum:10, //要展示的页码数量
            canJump: 1,// 是否能跳转。0=不显示（默认），1=显示
            showOne: 0,//只有一页时，是否显示。0=不显示,1=显示（默认）
            callback: function (num) { //回调函数
                $.ajax({
                    url: "/jzApi/experts/selExperts",
                    type: 'GET',
                    data: {
                        number:8,
                        current: num,
                        name: name,
                        type: 4
                    },
                    success:function (res) {
                        var list = res.data.records;
                        var news = '';
                        list.forEach(function (item, index) {
                            news += '<a href="/cultivate/teacherDetails?id='+item.userId+'"><div id="sz">' +
                                '<div class="tea_1">' +
                                '<img class="tea_2" src="'+item.headPortrait+'">' +
                                '<div class="tea_3">讲师姓名：'+item.name+'</div>' +
                                '<div class="tea_4">所属单位：'+item.orgName+'</div>' +
                                '<div class="tea_4">擅长领域：'+item.kpointsName+'</div>' +
                                '</div>' +
                                '</div></a>';
                        });
                        news +='<div style="clear: both"></div>';
                        $("#teach").html(news);
                    }
                });
            }
        });
    }
</script>
</html>